<template>
    <div class="container">
        <div class="header">
            <mt-header title="酒店列表">
                <router-link to="/address" slot="left">
                    <mt-button icon="back"></mt-button>
                </router-link>
            </mt-header>
            <div v-show=!isShow>本地暂无数据信息</div>
            <div v-show=isShow class="title" >
                <div v-for="(item, index) in data" :key="index">
                    <div class="body" @click="goDetail(item.id)">
                        <div class="body2">
                            <div class="img">
                                <img class="tupian" :src='baseUrl + item.cover' alt="">
                            </div>
                            <div class="name">
                                <div>
                                    {{ item.title }}
                                </div>
                                <div style="color: red;">
                                    ￥{{ item.price }}
                                </div>
                                <div class="tag">
                                    {{ item.tags }}
                                </div>
                                <div class="address" style="font-style: normal;">
                                    地址：{{ item.location }}
                                </div>
                            </div>
                        </div>

                    </div>

                </div>
            </div>
        </div>

    </div>
</template>
<script>

export default {
    data() {
        return {
            data: [],
            baseUrl: this.getBaseUrl(),
            city: '',
            isShow: true
        }
    },
    methods: {
        getUserInfo() {
            this.$axios({
                url: this.$api.houseList,
                method: 'get',
                params: {
                    city: this.city
                },
                Headers: { Authorization: 'Bearer' + this.$store.state.token }
            }).then(res => {
                if (res.rows.length < 1) {
                    this.isShow = false
                } else {
                    // console.log(res);
                    this.data = res.rows
                    // console.log(this.data);
                }

            })
        },
        goDetail(id) {
            this.$router.push({ name: 'hdetail', params: { jiu: id } })
        },
        getCity() {
            this.city = this.$route.query.city
        }
    },
    mounted() {
        this.getCity()
        this.getUserInfo()
    }
}
</script>
<style lang="scss" scoped>
* {
    margin: 0;
    padding: 0;
}

.container {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
}

/* body样式 */
.body {
  width: 100%;
  background-color: #fff;
  border: 1px solid #ccc;
  margin-bottom: 10px;
  padding: 10px;
  box-sizing: border-box;
  cursor: pointer;
  border-radius: 5px;
}

/* body2样式 */
.body2 {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

/* img样式 */
.img {
  width: 30%;
  padding-right: 10px;
  box-sizing: border-box;
}

/* tupian样式 */
.tupian {
  width: 100%;
  height: auto;
  border-radius: 4px;
}

/* name样式 */
.name {
  width: 70%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
}

/* tag样式 */
.tag {
  font-size: 14px;
  color: #999;
  margin-top: 10px;
}

/* address样式 */
.address {
  font-size: 14px;
  color: #999;
  margin-top: 10px;
}

</style>